import CacheUtil from "@/common/CacheUtil";

function back(){
	setTimeout(()=>{
		uni.navigateBack();
	}, 200)
}

function toHome(){
	console.log('toHome: ');
	CacheUtil.setLogin(true)
	uni.switchTab({
		url:'/pages/tab/game/game',
		fail: (error) => {
			console.log('toHome: ', JSON.stringify(error));
		}
	});
}

//隐私政策
function toAgreement(){
	getApp().globalData.webUrl = "https://www.xksndf2002.cn/agreement.html";
	uni.navigateTo({
		url: '/main/web/web'
	})
}
function toPrivacy(){
	getApp().globalData.webUrl = "https://www.xksndf2002.cn/privacy.html";
	uni.navigateTo({
		url: '/main/web/web'
	})
}

//注册相关
function toRegister(){
	uni.navigateTo({
		url: '/main/register/register'
	})
}
function toRegisterPassword(){
	uni.redirectTo({
		url: "/main/register/register-password"
	})
}
function toRegisterSex(){
	uni.navigateTo({
		url: "/main/register/register-sex",
	})
}
function toRegisterWhy(){
	CacheUtil.setLogin(true)
	uni.reLaunch({
		url: "/main/register/register-why",
	})
}
function toRegister1(){
	uni.navigateTo({
		url: "/main/register/register1"
	})
}
function toRegister2(){
	uni.navigateTo({
		url: "/main/register/register2"
	})
}
function toRegister3(){
	uni.navigateTo({
		url: "/main/register/register3"
	})
}
function toRegister4(){
	uni.navigateTo({
		url: "/main/register/register4"
	})
}
function toRegister5(){
	uni.navigateTo({
		url: "/main/register/register5"
	})
}
function toRegister6(){
	uni.navigateTo({
		url: "/main/register/register6"
	})
}
function toRegister7(){
	uni.navigateTo({
		url: "/main/register/register7"
	})
}
function toRegister8(){
	uni.navigateTo({
		url: "/main/register/register8"
	})
}
function toRegister9(){
	uni.navigateTo({
		url: "/main/register/register9"
	})
}

//我的相关
function toVisit(){
	uni.navigateTo({
		url:'/main/mine/visit/visit'
	})
}
function toSetPrivacy(){
	uni.navigateTo({
		url:'/main/mine/setting/privacy/privacy'
	})
}
function toAccount(){
	uni.navigateTo({
		url:'/main/mine/account/account'
	})
}
function toUpdatePassword(){
	uni.navigateTo({
		url:'/main/mine/password/password'
	})
}
function toVip(){
	uni.navigateTo({
		url: '/main/mine/vip/vip'
	})
}
function toRealname(){
	uni.navigateTo({
		url: '/main/mine/realname/realname'
	})
}
function toAuth(){
	uni.navigateTo({
		url: '/main/mine/auth/auth'
	})
}
function toSetting(){
	uni.navigateTo({
		url: '/main/mine/setting/setting'
	})
}

//消息公告
function toNoticeDetail(params){
	uni.navigateTo({
		url: '/main/notice/detail/detail',
		success: res => {
			res.eventChannel.emit('sendData', params);
		},
		fail: res => {
			console.log('item', JSON.stringify(res));
		},
	})
}
function toNoticeList(){
	uni.navigateTo({
		url:'/main/notice/list/list'
	})
}

//用户相关
function toUserEdit(userId){
	uni.navigateTo({
		url: '/main/user/edit/edit?userId=' + userId
	})
}
function toUserEditTag(user){
	uni.navigateTo({
		url: '/main/user/edit/tag/tag?userId=' + user.id + "&tagIds=" + user.tagIds,
	})
}
function toUserEditContent(data){
	uni.navigateTo({
		url: '/main/user/edit/content/content?type=' + data.type + "&content="+data.content
	})
}
function toUserEditPhoto(){
	uni.navigateTo({
		url: '/main/user/edit/photo/photo'
	})
}
function toUserInfo(txCode){
	uni.navigateTo({
		url: '/main/user/info/info?txCode=' + txCode
	})
}

// type:1.所有, 2.个人
function toDynamicPerson(type, userId){
	uni.navigateTo({
		url: '/main/dynamic/person/person?userId=' + userId + '&type='+type,
	});
}
function toDynamicRelease(){
	uni.navigateTo({
		url: '/main/dynamic/release/release'
	})
}
function toDynamicComment(data){
	uni.navigateTo({
		url:'/main/dynamic/comment/comment',
		success: res => {
			res.eventChannel.emit('sendData', data);
		},
	})
}

//搭子
function toGameRelease(){
	uni.navigateTo({
		url:'/pages/game/release'
	})
}
function toGameDetail(data){
	uni.navigateTo({
		url:'/pages/game/detail',
		success: res => {
			res.eventChannel.emit('sendData', data);
		},
	})
}

//人气榜
function toRanking(){
	uni.navigateTo({
		url:'/main/ranking/ranking',
	})
}
function toVote(){
	uni.navigateTo({
		url:'/main/vote/vote',
	})
}
//举报
function toReport(userId){
	uni.navigateTo({
		url:'/main/report/report?userId='+userId,
	})
}


export default {
	back,
	toHome,
	//隐私政策
	toAgreement,
	toPrivacy,
	//注册相关
	toRegister,
	toRegisterPassword,
	toRegisterSex,
	toRegisterWhy,
	toRegister1,
	toRegister2,
	toRegister3,
	toRegister4,
	toRegister5,
	toRegister6,
	toRegister7,
	toRegister8,
	toRegister9,
	//我的相关
	toVisit,
	toAccount,
	toUpdatePassword,
	toVip,
	toRealname,
	toAuth,
	toSetting,
	toSetPrivacy,
	//消息公告
	toNoticeDetail,
	toNoticeList,
	//用户
	toUserEdit,
	toUserEditTag,
	toUserEditContent,
	toUserEditPhoto,
	toUserInfo,
	//动态
	toDynamicPerson,
	toDynamicRelease,
	toDynamicComment,
	//搭圈
	toGameRelease,
	toGameDetail,
	//人气榜
	toRanking,
	toVote,
	//举报
	toReport
	
}